if (!jsx3.lang.Class.forName("ux.cdb.admin.system.import.Import")) {
    /**
     * Define the <code>name of class</code> class.
     * This class inherit from <code>jsx3.gui.Block<code> GUI class.
     */
    jsx3.Class.defineClass(
            "ux.cdb.admin.system.import.Import",
            ux.megatron.gui.Block,
            null,
            function (objRoot) {
				
				var formUpload = null;
				var frameUpload = null;
				var btnUpload = null;
				var btnConvert = null;
				var lblStatus = null;
				
				objRoot.prototype.initialize = function(){
					
				};
				
				objRoot.prototype.onAfterPaint = function(){
					formUpload = document.getElementById("uploadform");
					frameUpload = document.getElementById("hiddenframe");
					btnUpload = this.getDescendantOfName("btnUpload");
					btnConvert = this.getDescendantOfName("btnConvert");
					lblStatus = this.getDescendantOfName("lblStatus");
				};
				
				objRoot.prototype.onFileChanged = function(htmlfileObj){
		
					btnUpload.setEnabled(jsx3.gui.Form.STATEENABLED,true);

				};
				
				objRoot.prototype.startUpload = function(){
					var uploadFileName = formUpload.newfile.value;
					var extName = uploadFileName.toLowerCase().substring(uploadFileName.lastIndexOf('.')+1, uploadFileName.length);
					jsx3.log("startUpload uploadFileName[ext:"+extName+"]:"+uploadFileName);
					try{
						if(extName != 'xls' && extName != 'zip'){
							lblStatus.setText(ux.megatron.Main.getServer().getDynamicProperty("@cdb@System@Import@incorrectFile"),true);
							return;
						}
						
						/* var fileSize = this.getFileSize(uploadFileName);
						jsx3.log("startUpload fileSize:"+fileSize);
						if(fileSize>10*1024){
							lblStatus.setText(ux.megatron.Main.getServer().getDynamicProperty("@cdb@System@Import@incorrectFileSize"),true);
							return;
						} */							
					}catch(e){
						jsx3.log(e.message);
					}
					lblStatus.setText(ux.megatron.Main.getServer().getDynamicProperty("@cdb@System@Import@uploading"),true);
					btnUpload.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
					this.get('blkUploading').show();
					formUpload.submit();
					var me = this;
					setTimeout(function(){me.checkUploadStatus();},3000);
				};
				
				objRoot.prototype.getFileSize = function(fileName){  
					try{       		  
			          	var  fso = new ActiveXObject('Scripting.FileSystemObject');   
			          	var  File = fso.GetFile(fileName);     
			          	return File.size;   
			      	}catch(e){
			      		jsx3.log("getFileSize error:"+e.message);
			      	}
				}

				
				objRoot.prototype.checkUploadStatus = function(){
					var me = this;
					ux.megatron.util.Dwr.callDwr("StateUCC", "getUploadState", [], me, me.onCheckReturn);
				}
				
                objRoot.prototype.onCheckReturn = function(reData) {
                    var me = this;
                    //console.log("reData:" + JSON.stringify(reData));
                    if (!reData) {
                        setTimeout(function(){me.checkUploadStatus();},2000);
                    }

                    var flag = reData.res.flag;
                    if (flag == 1) { //success
                        this.filename = reData.content.data[0];
					    lblStatus.setText(ux.megatron.Main.getServer().getDynamicProperty("@cdb@System@Import@uploadSuccessful"),true);
					    btnConvert.setEnabled(jsx3.gui.Form.STATEENABLED,true);
						this.get('blkUploading').hide();
                    } else if (flag == -1) { //uploading
                        setTimeout(function(){me.checkUploadStatus();},2000);
						this.get('blkUploading').hide();
                    } else if (flag == 0) { //failed
					    lblStatus.setText(reData.res.msg,true);
						this.get('blkUploading').hide();
                        return;
                    }
                }
				
		objRoot.prototype.startConvert = function(){
			lblStatus.setText(ux.megatron.Main.getServer().getDynamicProperty("@cdb@System@Import@importing"),true);
			btnUpload.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
			btnConvert.setEnabled(jsx3.gui.Form.STATEDISABLED,true);
			this.get('blkUploading').show();
			var me = this;
			ux.megatron.util.Dwr.callDwr("ImportExcelSummaryInfoUCC", "importExcel", [me.filename], me, me.onConvert);
		};
                
		objRoot.prototype.onConvert = function(reData){
				lblStatus.setText(ux.megatron.Main.getServer().getDynamicProperty("@cdb@System@Import@importDone"),true);
				//lblStatus.setText(reData.res.msg,true);
				this.get('blkUploading').hide();
				var flag = reData.res.flag;

			if(flag != 1){
				var msg = reData.res.msg;
				alert(msg);
				jsx3.log("call startConvert failed: "+msg);
				return;
			} 
        		
        		this.get("block_afterImport").setDisplay(jsx3.gui.Block.DISPLAYBLOCK,true);
        		var realData = reData.content.data[0];
        	try{
        		var dataAll = realData.tatal;
        		var importSuccessNumber = realData.success;
        		//var certIdDuplicatn = realData.repeat;
        		var exceptionDatan = realData.failed;
        		
        		this.repeatUrl = realData.repeatUrl ? realData.repeatUrl : "";
        		this.failedUrl = realData.failedUrl ? realData.failedUrl : "";

				if(this.failedUrl == "" || parseInt(exceptionDatan) == 0){
					this.get("labelExceptionDataAddress").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
				}
        		
        		this.get("lblValue_dataAll").setText(dataAll,true);
        		this.get("importSuccessNumber").setText(importSuccessNumber,true);
        		this.get("exceptionData").setText(exceptionDatan,true);

        		//var urlTest = "http://www.sohu.com";
        		//alert(document.getElementById("had").href);
        		//document.getElementById("hrRepeat").href = this.repeatUrl;
        		//document.getElementById("hrException").href = this.failedUrl;
        		//document.all.had.href = urlTest;
        		//this.get("label_repeatURL").setText(urlTest,true);
        		
/* @JSC :: begin DEBUG */
        		jsx3.log("dataAll: "+ dataAll);
        		jsx3.log("importSuccessNumber: "+ importSuccessNumber);
        		//jsx3.log("certIdDuplicatn: "+ certIdDuplicatn);
        		jsx3.log("exceptionDatan: "+ exceptionDatan);
        		jsx3.log("repeatUrl: "+ this.repeatUrl);
        		jsx3.log("failedUrl: "+ this.failedUrl);
/* @JSC :: end */
        	}catch(e){
        		jsx3.log("call startConvert failed: "+ e.message);
        	}   			 
        }
				
		objRoot.prototype.hrRepeat_onclick = function(){
			this.get("iframeExport").setSrc(this.repeatUrl);
		}
				
		objRoot.prototype.hrException_onclick = function(){
			this.get("iframeExport").setSrc(this.failedUrl);
		}
				
		objRoot.prototype.onContent = function(){
			if(frameUpload.getAttribute('src') != 'about:blank'){
				if(frameUpload.contentWindow){

				}else if(frameUpload.contentDocument){

				}
				//console.log(frameUpload.contentWindow,frameUpload.contentDocument);
			}
		}
				
	}
    );
}